var fs = require("fs")
const qs = require('qs')
const jwt = require("jsonwebtoken")
const express = require('express')
const { resourceUsage } = require('process')

var mypersonrouter = express.Router()
var axios = require("axios");
const { JsonWebTokenError } = require("jsonwebtoken");


mypersonrouter.get('/myperson', function (req, res) {
    if (req.session.token == undefined){
        axios({
            url: "video/order/findAllVip",
            method: "post",
})
    .then(function (data) {
        let allonevip = data.data.object
        res.render('front-stage/myperson.html', { userinfo: '', allonevip: allonevip })
    })
    .catch(function (error) {
        console.log(error)
        res.status(500).json({
            message: '黄金vip遍历失败'
        })
    })
       

    }else{
        axios({
            url: "video/fan/myAttention",
            method: "get",
            params: {
                userId: jwt.decode(req.session.token).userId    
            }
        })
            .then(function (data) {
              
                let gzinfo  = data.data.data
               
                        let userallvideo = data.data.data.allVideo
                                    axios({
                                        url: "video/order/findAllVip",
                                        method: "post",
                                    })
                                        .then(function (data) {
                                            
                                            let allonevip = data.data.object
                                            axios({
                                                url: "video/fan/myFans",
                                                method: "GET",
                                                params: {
                                                    userId: jwt.decode(req.session.token).userId
                                                }
                                            })
                                                .then(function (data) {
                                                    let info = data.data.data;
                                                    console.log(info);
                                                    axios({
                                                        url: "video/verify/findAllVideoVerify",
                                                        method: "get",
                                                        params: {
                                                            userId: jwt.decode(req.session.token).userId,
                                                        }
                                                    })
                                                        .then(function (data) {
                                                            let nosuccessvideo = data.data.data.未通过;
                                                            let allvideo = data.data.data.全部的视频审核结果;
                                                            let alreadysuccessvideo = data.data.data.已通过;
                                                            let ingvideo = data.data.data.未审核;


                                                            axios({
                                                                url: "video/findRecordByUserId",
                                                                method: "get",
                                                                params: {
                                                                    userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                }
                                                            })
                                                                .then(function (data) {
                                                                   
                                                                    let userhistory = data.data.object


                                                                    axios({
                                                                        url: "video/findRecordByVideoTypeNameLike",
                                                                        method: "get",
                                                                        params: {
                                                                            userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                            videoType: "电影",
                                                                        }
                                                                    })
                                                                        .then(function (data) {
                                                                           
                                                                            let userdyhistory = data.data.object
                                                                            axios({
                                                                                url: "video/findRecordByVideoTypeNameLike",
                                                                                method: "get",
                                                                                params: {
                                                                                    userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                    videoType: "电视剧",
                                                                                }
                                                                            })
                                                                                .then(function (data) {
                                                                                   
                                                                                    let userdsjhistory = data.data.object
                                                                                    axios({
                                                                                        url: "video/findRecordByVideoTypeNameLike",
                                                                                        method: "get",
                                                                                        params: {
                                                                                            userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                            videoType: "综艺",
                                                                                        }
                                                                                    })
                                                                                        .then(function (data) {
                                                                                          
                                                                                            let userzyhistory = data.data.object
                                                                                            axios({
                                                                                                url: "video/findRecordByVideoTypeNameLike",
                                                                                                method: "get",
                                                                                                params: {
                                                                                                    userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                                    videoType: "动漫",
                                                                                                }
                                                                                            })
                                                                                                .then(function (data) {
                                                                                                    console.log(data.data)
                                                                                                    let userdmhistory = data.data.object


                                                                                                                            axios({
                                                                                                                                url: "video/user/findUserById",
                                                                                                                                params: {
                                                                                                                                    userId: jwt.decode(req.session.token).userId,
                                                                                                                                },
                                                                                                                                method: "get",
                                                                                                                            })
                                                                                                                                .then(function (data) {
                                                                                                                                   
                                                                                                                                    let viptype = data.data.object.vip;
                                                                                                                                    
                                                                                                                                    if (viptype == "0") {
                                                                                                                                        console.log("普通用户")
                                                                                                                                        res.render('front-stage/myperson.html', { viptype: viptype,userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory,   userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                                                     } else if (viptype == "1") {
                                                                                                                                         console.log("vip用户")
                                                                                                                                        res.render('front-stage/myperson.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory,  userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                                                    } else {
                                                                                                                                        console.log("管理员")
                                                                                                                                        res.render('front-stage/myperson.html', { viptype: viptype,userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                                                    }






                                                                                                                                })
                                                                                                                                .catch(function (error) {
                                                                                                                                  
                                                                                                                                    res.status(500).json({
                                                                                                                                        message: '获取用户信息失败'
                                                                                                                                    })
                                                                                                                                })

                                                                                                })
                                                                                                .catch(function (error) {
                                                                                                    
                                                                                                    res.status(500).json({
                                                                                                        message: '遍历电影观看记录失败'
                                                                                                    })
                                                                                                })


                                                                                        })
                                                                                        .catch(function (error) {
                                                                                           
                                                                                            res.status(500).json({
                                                                                                message: '遍历电影观看记录失败'
                                                                                            })
                                                                                        })


                                                                                })
                                                                                .catch(function (error) {
                                                                                   
                                                                                    res.status(500).json({
                                                                                        message: '遍历电影观看记录失败'
                                                                                    })
                                                                                })


                                                                        })
                                                                        .catch(function (error) {
                                                                            
                                                                            res.status(500).json({
                                                                                message: '遍历电影观看记录失败'
                                                                            })
                                                                        })





                                                                })
                                                                .catch(function (error) {
                                                                   
                                                                    res.status(500).json({
                                                                        message: '遍历观看记录失败'
                                                                    })
                                                                })






                                                        })
                                                        .catch(function (error) {
                                                           
                                                            res.status(500).json({
                                                                message: '查看用户的视频审核记录失败'
                                                            })
                                                        })


                                         
                            })
                            .catch(function (error) {
                                res.status(500).json({
                                    message: '获取粉丝列表失败'
                                })
                            })


                            })
                            .catch(function (error) {
                               
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })


             })
            .catch(function (error) {
                res.status(500).json({
                    message: '获取关注列表失败'
                })
            })
    }

})
mypersonrouter.get('/creatCenter', function (req, res) {
    if (req.session.token == undefined) {
        axios({
            url: "video/order/findAllVip",
            method: "post",
        })
            .then(function (data) {
                let allonevip = data.data.object
                res.render('front-stage/creatCenter.html', { userinfo: '', allonevip: allonevip })
            })
            .catch(function (error) {
            
                res.status(500).json({
                    message: '黄金vip遍历失败'
                })
            })


    } else {
        axios({
            url: "video/fan/myAttention",
            method: "GET",
            params: {
                userId: jwt.decode(req.session.token).userId
            }
        })
            .then(function (data) {
                let gzinfo = data.data.data
                        axios({
                            url: "video/order/findAllVip",
                            method: "post",
                        })
                            .then(function (data) {

                                let allonevip = data.data.object
                                axios({
                                    url: "video/fan/myFans",
                                    method: "GET",
                                    params: {
                                        userId: jwt.decode(req.session.token).userId
                                    }
                                })
                                    .then(function (data) {
                                        let info = data.data.data;                                      
                                        axios({
                                            url: "video/verify/findAllVideoVerify",
                                            method: "get",
                                            params: {
                                                userId: jwt.decode(req.session.token).userId,
                                            }
                                        })
                                            .then(function (data) {
                                                let nosuccessvideo = data.data.data.未通过;
                                                let allvideo = data.data.data.全部的视频审核结果;
                                                let alreadysuccessvideo = data.data.data.已通过;
                                                let ingvideo = data.data.data.未审核;
                                                axios({
                                                    url: "video/findRecordByUserId",
                                                    method: "get",
                                                    params: {
                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                    }
                                                })
                                                    .then(function (data) {
                                                        // console.log(data.data.object)
                                                        let userhistory = data.data.object


                                                        axios({
                                                            url: "video/findRecordByVideoTypeNameLike",
                                                            method: "get",
                                                            params: {
                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                videoType: "电影",
                                                            }
                                                        })
                                                            .then(function (data) {
                                                                
                                                                let userdyhistory = data.data.object
                                                                axios({
                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                    method: "get",
                                                                    params: {
                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                        videoType: "电视剧",
                                                                    }
                                                                })
                                                                    .then(function (data) {
                                                                       
                                                                        let userdsjhistory = data.data.object
                                                                        axios({
                                                                            url: "video/findRecordByVideoTypeNameLike",
                                                                            method: "get",
                                                                            params: {
                                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                videoType: "综艺",
                                                                            }
                                                                        })
                                                                            .then(function (data) {
                                                                              
                                                                                let userzyhistory = data.data.object
                                                                                axios({
                                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                                    method: "get",
                                                                                    params: {
                                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                        videoType: "动漫",
                                                                                    }
                                                                                })
                                                                                    .then(function (data) {
                                                                                       
                                                                                        let userdmhistory = data.data.object


                                                                                        axios({
                                                                                            url: "video/user/findUserById",
                                                                                            params: {
                                                                                                userId: jwt.decode(req.session.token).userId,
                                                                                            },
                                                                                            method: "get",
                                                                                        })
                                                                                            .then(function (data) {
                                                                                              
                                                                                                let viptype = data.data.object.vip;
                                                                                               
                                                                                                if (viptype == "0") {
                                                                                                    console.log("普通用户")
                                                                                                    res.render('front-stage/creatCenter.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else if (viptype == "1") {
                                                                                                    console.log("vip用户")
                                                                                                    res.render('front-stage/creatCenter.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else {
                                                                                                    console.log("管理员")
                                                                                                    res.render('front-stage/creatCenter.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                }






                                                                                            })
                                                                                            .catch(function (error) {
                                                                                               
                                                                                                res.status(500).json({
                                                                                                    message: '获取用户信息失败'
                                                                                                })
                                                                                            })













                                                                                    })
                                                                                    .catch(function (error) {
                                                                                       
                                                                                        res.status(500).json({
                                                                                            message: '遍历电影观看记录失败'
                                                                                        })
                                                                                    })


                                                                            })
                                                                            .catch(function (error) {
                                                                              
                                                                                res.status(500).json({
                                                                                    message: '遍历电影观看记录失败'
                                                                                })
                                                                            })


                                                                    })
                                                                    .catch(function (error) {
                                                                       
                                                                        res.status(500).json({
                                                                            message: '遍历电影观看记录失败'
                                                                        })
                                                                    })


                                                            })
                                                            .catch(function (error) {
                                                               
                                                                res.status(500).json({
                                                                    message: '遍历电影观看记录失败'
                                                                })
                                                            })





                                                    })
                                                    .catch(function (error) {
                                                        
                                                        res.status(500).json({
                                                            message: '遍历观看记录失败'
                                                        })
                                                    })






                                            })
                                            .catch(function (error) {
                                                
                                                res.status(500).json({
                                                    message: '查看用户的视频审核记录失败'
                                                })
                                            })



                                    })
                                    .catch(function (error) {
                                        res.status(500).json({
                                            message: '获取粉丝列表失败'
                                        })
                                    })


                            })
                            .catch(function (error) {
                               
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })

                    })

    }


})
mypersonrouter.get('/message', function (req, res) {
    if (req.session.token == undefined) {
        axios({
            url: "video/order/findAllVip",
            method: "post",
        })
            .then(function (data) {
                let allonevip = data.data.object
                res.render('front-stage/message.html', { userinfo: '', allonevip: allonevip })
            })
            .catch(function (error) {
                console.log(error)
                res.status(500).json({
                    message: '黄金vip遍历失败'
                })
            })


    } else {
        axios({
            url: "video/fan/myAttention",
            method: "GET",
            params: {
                userId: jwt.decode(req.session.token).userId
            }
        })
            .then(function (data) {
                let gzinfo = data.data.data
                        axios({
                            url: "video/order/findAllVip",
                            method: "post",
                        })
                            .then(function (data) {

                                let allonevip = data.data.object
                                axios({
                                    url: "video/fan/myFans",
                                    method: "GET",
                                    params: {
                                        userId: jwt.decode(req.session.token).userId
                                    }
                                })
                                    .then(function (data) {
                                        let info = data.data.data;
                                        console.log(info);




                                        axios({
                                            url: "video/verify/findAllVideoVerify",
                                            method: "get",
                                            params: {
                                                userId: jwt.decode(req.session.token).userId,
                                            }
                                        })
                                            .then(function (data) {
                                                let nosuccessvideo = data.data.data.未通过;
                                                let allvideo = data.data.data.全部的视频审核结果;
                                                let alreadysuccessvideo = data.data.data.已通过;
                                                let ingvideo = data.data.data.未审核;


                                                axios({
                                                    url: "video/findRecordByUserId",
                                                    method: "get",
                                                    params: {
                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                    }
                                                })
                                                    .then(function (data) {
                                                        // console.log(data.data.object)
                                                        let userhistory = data.data.object


                                                        axios({
                                                            url: "video/findRecordByVideoTypeNameLike",
                                                            method: "get",
                                                            params: {
                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                videoType: "电影",
                                                            }
                                                        })
                                                            .then(function (data) {
                                                                console.log(data.data)
                                                                let userdyhistory = data.data.object
                                                                axios({
                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                    method: "get",
                                                                    params: {
                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                        videoType: "电视剧",
                                                                    }
                                                                })
                                                                    .then(function (data) {
                                                                       
                                                                        let userdsjhistory = data.data.object
                                                                        axios({
                                                                            url: "video/findRecordByVideoTypeNameLike",
                                                                            method: "get",
                                                                            params: {
                                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                videoType: "综艺",
                                                                            }
                                                                        })
                                                                            .then(function (data) {
                                                                               
                                                                                let userzyhistory = data.data.object
                                                                                axios({
                                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                                    method: "get",
                                                                                    params: {
                                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                        videoType: "动漫",
                                                                                    }
                                                                                })
                                                                                    .then(function (data) {
                                                                                       
                                                                                        let userdmhistory = data.data.object


                                                                                        axios({
                                                                                            url: "video/user/findUserById",
                                                                                            params: {
                                                                                                userId: jwt.decode(req.session.token).userId,
                                                                                            },
                                                                                            method: "get",
                                                                                        })
                                                                                            .then(function (data) {
                                                                                                
                                                                                                let viptype = data.data.object.vip;
                                                                                                console.log(viptype);
                                                                                                if (viptype == "0") {
                                                                                                    console.log("普通用户")
                                                                                                    res.render('front-stage/message.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else if (viptype == "1") {
                                                                                                    console.log("vip用户")
                                                                                                    res.render('front-stage/message.html', { viptype: viptype,userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else {
                                                                                                    console.log("管理员")
                                                                                                    res.render('front-stage/message.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                }

                                                                                            })
                                                                                            .catch(function (error) {
                                                                                              
                                                                                                res.status(500).json({
                                                                                                    message: '获取用户信息失败'
                                                                                                })
                                                                                            })













                                                                                    })
                                                                                    .catch(function (error) {
                                                                                        console.log(error)
                                                                                        res.status(500).json({
                                                                                            message: '遍历电影观看记录失败'
                                                                                        })
                                                                                    })


                                                                            })
                                                                            .catch(function (error) {
                                                                                console.log(error)
                                                                                res.status(500).json({
                                                                                    message: '遍历电影观看记录失败'
                                                                                })
                                                                            })


                                                                    })
                                                                    .catch(function (error) {
                                                                        console.log(error)
                                                                        res.status(500).json({
                                                                            message: '遍历电影观看记录失败'
                                                                        })
                                                                    })


                                                            })
                                                            .catch(function (error) {
                                                                console.log(error)
                                                                res.status(500).json({
                                                                    message: '遍历电影观看记录失败'
                                                                })
                                                            })





                                                    })
                                                    .catch(function (error) {
                                                        console.log(error)
                                                        res.status(500).json({
                                                            message: '遍历观看记录失败'
                                                        })
                                                    })






                                            })
                                            .catch(function (error) {
                                               
                                                res.status(500).json({
                                                    message: '查看用户的视频审核记录失败'
                                                })
                                            })



                                    })
                                    .catch(function (error) {
                                        res.status(500).json({
                                            message: '获取粉丝列表失败'
                                        })
                                    })


                            })
                            .catch(function (error) {
                              
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })


            })
            .catch(function (error) {
                res.status(500).json({
                    message: '获取关注列表失败'
                })
            })
    }

})
mypersonrouter.get('/sc', function (req, res) {
    if (req.session.token == undefined) {
        axios({
            url: "video/order/findAllVip",
            method: "post",
        })
            .then(function (data) {
                let allonevip = data.data.object
                res.render('front-stage/sc.html', { userinfo: '', allonevip: allonevip })
            })
            .catch(function (error) {
              
                res.status(500).json({
                    message: '黄金vip遍历失败'
                })
            })


    } else {
        axios({
            url: "video/fan/myAttention",
            method: "GET",
            params: {
                userId: jwt.decode(req.session.token).userId
            }
        })
            .then(function (data) {
                let gzinfo = data.data.data
                        axios({
                            url: "video/order/findAllVip",
                            method: "post",
                        })
                            .then(function (data) {

                                let allonevip = data.data.object
                                axios({
                                    url: "video/fan/myFans",
                                    method: "GET",
                                    params: {
                                        userId: jwt.decode(req.session.token).userId
                                    }
                                })
                                    .then(function (data) {
                                        let info = data.data.data;
                                     
                                        axios({
                                            url: "video/verify/findAllVideoVerify",
                                            method: "get",
                                            params: {
                                                userId: jwt.decode(req.session.token).userId,
                                            }
                                        })
                                            .then(function (data) {
                                                let nosuccessvideo = data.data.data.未通过;
                                                let allvideo = data.data.data.全部的视频审核结果;
                                                let alreadysuccessvideo = data.data.data.已通过;
                                                let ingvideo = data.data.data.未审核;


                                                axios({
                                                    url: "video/findRecordByUserId",
                                                    method: "get",
                                                    params: {
                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                    }
                                                })
                                                    .then(function (data) {
                                                        // console.log(data.data.object)
                                                        let userhistory = data.data.object


                                                        axios({
                                                            url: "video/findRecordByVideoTypeNameLike",
                                                            method: "get",
                                                            params: {
                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                videoType: "电影",
                                                            }
                                                        })
                                                            .then(function (data) {
                                                               
                                                                let userdyhistory = data.data.object
                                                                axios({
                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                    method: "get",
                                                                    params: {
                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                        videoType: "电视剧",
                                                                    }
                                                                })
                                                                    .then(function (data) {
                                                                        
                                                                        let userdsjhistory = data.data.object
                                                                        axios({
                                                                            url: "video/findRecordByVideoTypeNameLike",
                                                                            method: "get",
                                                                            params: {
                                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                videoType: "综艺",
                                                                            }
                                                                        })
                                                                            .then(function (data) {
                                                                               
                                                                                let userzyhistory = data.data.object
                                                                                axios({
                                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                                    method: "get",
                                                                                    params: {
                                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                        videoType: "动漫",
                                                                                    }
                                                                                })
                                                                                    .then(function (data) {
                                                                                       
                                                                                        let userdmhistory = data.data.object


                                                                                        axios({
                                                                                            url: "video/user/findUserById",
                                                                                            params: {
                                                                                                userId: jwt.decode(req.session.token).userId,
                                                                                            },
                                                                                            method: "get",
                                                                                        })
                                                                                            .then(function (data) {
                                                                                               
                                                                                                let viptype = data.data.object.vip;
                                                                                                console.log(viptype);
                                                                                                if (viptype == "0") {
                                                                                                    console.log("普通用户")
                                                                                                    res.render('front-stage/sc.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else if (viptype == "1") {
                                                                                                    console.log("vip用户")
                                                                                                    res.render('front-stage/sc.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else {
                                                                                                    console.log("管理员")
                                                                                                    res.render('front-stage/sc.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                }

                                                                                            })
                                                                                            .catch(function (error) {
                                                                                               
                                                                                                res.status(500).json({
                                                                                                    message: '获取用户信息失败'
                                                                                                })
                                                                                            })













                                                                                    })
                                                                                    .catch(function (error) {
                                                                                      
                                                                                        res.status(500).json({
                                                                                            message: '遍历电影观看记录失败'
                                                                                        })
                                                                                    })


                                                                            })
                                                                            .catch(function (error) {
                                                                               
                                                                                res.status(500).json({
                                                                                    message: '遍历电影观看记录失败'
                                                                                })
                                                                            })


                                                                    })
                                                                    .catch(function (error) {
                                                                        
                                                                        res.status(500).json({
                                                                            message: '遍历电影观看记录失败'
                                                                        })
                                                                    })


                                                            })
                                                            .catch(function (error) {
                                                               
                                                                res.status(500).json({
                                                                    message: '遍历电影观看记录失败'
                                                                })
                                                            })





                                                    })
                                                    .catch(function (error) {
                                                       
                                                        res.status(500).json({
                                                            message: '遍历观看记录失败'
                                                        })
                                                    })






                                            })
                                            .catch(function (error) {
                                               
                                                res.status(500).json({
                                                    message: '查看用户的视频审核记录失败'
                                                })
                                            })



                                    })
                                    .catch(function (error) {
                                        res.status(500).json({
                                            message: '获取粉丝列表失败'
                                        })
                                    })


                            })
                            .catch(function (error) {
                               
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })


            })
            .catch(function (error) {
                res.status(500).json({
                    message: '获取关注列表失败'
                })
            })
    }
})
mypersonrouter.get('/sz', function (req, res) {
    if (req.session.token == undefined) {
        axios({
            url: "video/order/findAllVip",
            method: "post",
        })
            .then(function (data) {
                let allonevip = data.data.object
                res.render('front-stage/sz.html', { userinfo: '', allonevip: allonevip })
            })
            .catch(function (error) {
               
                res.status(500).json({
                    message: '黄金vip遍历失败'
                })
            })


    } else {
        axios({
            url: "video/fan/myAttention",
            method: "GET",
            params: {
                userId: jwt.decode(req.session.token).userId
            }
        })
            .then(function (data) {
                let gzinfo = data.data.data
                        axios({
                            url: "video/order/findAllVip",
                            method: "post",
                        })
                            .then(function (data) {

                                let allonevip = data.data.object
                                axios({
                                    url: "video/fan/myFans",
                                    method: "GET",
                                    params: {
                                        userId: jwt.decode(req.session.token).userId
                                    }
                                })
                                    .then(function (data) {
                                        let info = data.data.data;
                                       

                                        axios({
                                            url: "video/verify/findAllVideoVerify",
                                            method: "get",
                                            params: {
                                                userId: jwt.decode(req.session.token).userId,
                                            }
                                        })
                                            .then(function (data) {
                                                let nosuccessvideo = data.data.data.未通过;
                                                let allvideo = data.data.data.全部的视频审核结果;
                                                let alreadysuccessvideo = data.data.data.已通过;
                                                let ingvideo = data.data.data.未审核;


                                                axios({
                                                    url: "video/findRecordByUserId",
                                                    method: "get",
                                                    params: {
                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                    }
                                                })
                                                    .then(function (data) {
                                                       
                                                        let userhistory = data.data.object


                                                        axios({
                                                            url: "video/findRecordByVideoTypeNameLike",
                                                            method: "get",
                                                            params: {
                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                videoType: "电影",
                                                            }
                                                        })
                                                            .then(function (data) {
                                                               
                                                                let userdyhistory = data.data.object
                                                                axios({
                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                    method: "get",
                                                                    params: {
                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                        videoType: "电视剧",
                                                                    }
                                                                })
                                                                    .then(function (data) {
                                                                      
                                                                        let userdsjhistory = data.data.object
                                                                        axios({
                                                                            url: "video/findRecordByVideoTypeNameLike",
                                                                            method: "get",
                                                                            params: {
                                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                videoType: "综艺",
                                                                            }
                                                                        })
                                                                            .then(function (data) {
                                                                              
                                                                                let userzyhistory = data.data.object
                                                                                axios({
                                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                                    method: "get",
                                                                                    params: {
                                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                        videoType: "动漫",
                                                                                    }
                                                                                })
                                                                                    .then(function (data) {
                                                                                      
                                                                                        let userdmhistory = data.data.object


                                                                                        axios({
                                                                                            url: "video/user/findUserById",
                                                                                            params: {
                                                                                                userId: jwt.decode(req.session.token).userId,
                                                                                            },
                                                                                            method: "get",
                                                                                        })
                                                                                            .then(function (data) {
                                                                                              
                                                                                                let viptype = data.data.object.vip;
                                                                                             
                                                                                                if (viptype == "0") {
                                                                                                    console.log("普通用户")
                                                                                                    res.render('front-stage/sz.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else if (viptype == "1") {
                                                                                                    console.log("vip用户")
                                                                                                    res.render('front-stage/sz.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else {
                                                                                                    console.log("管理员")
                                                                                                    res.render('front-stage/sz.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                }
                                                                                            })
                                                                                            .catch(function (error) {
                                                                                                console.log(error)
                                                                                                res.status(500).json({
                                                                                                    message: '获取用户信息失败'
                                                                                                })
                                                                                            })













                                                                                    })
                                                                                    .catch(function (error) {
                                                                                        console.log(error)
                                                                                        res.status(500).json({
                                                                                            message: '遍历电影观看记录失败'
                                                                                        })
                                                                                    })


                                                                            })
                                                                            .catch(function (error) {
                                                                                console.log(error)
                                                                                res.status(500).json({
                                                                                    message: '遍历电影观看记录失败'
                                                                                })
                                                                            })


                                                                    })
                                                                    .catch(function (error) {
                                                                        console.log(error)
                                                                        res.status(500).json({
                                                                            message: '遍历电影观看记录失败'
                                                                        })
                                                                    })


                                                            })
                                                            .catch(function (error) {
                                                                console.log(error)
                                                                res.status(500).json({
                                                                    message: '遍历电影观看记录失败'
                                                                })
                                                            })





                                                    })
                                                    .catch(function (error) {
                                                        console.log(error)
                                                        res.status(500).json({
                                                            message: '遍历观看记录失败'
                                                        })
                                                    })






                                            })
                                            .catch(function (error) {
                                                console.log(error)
                                                res.status(500).json({
                                                    message: '查看用户的视频审核记录失败'
                                                })
                                            })



                                    })
                                    .catch(function (error) {
                                        res.status(500).json({
                                            message: '获取粉丝列表失败'
                                        })
                                    })


                            })
                            .catch(function (error) {
                                console.log(error)
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })


            })
            .catch(function (error) {
                res.status(500).json({
                    message: '获取关注列表失败'
                })
            })
    }
})
mypersonrouter.get('/myload', function (req, res) {
    if (req.session.token == undefined) {
        axios({
            url: "video/order/findAllVip",
            method: "post",
        })
            .then(function (data) {
                let allonevip = data.data.object
                res.render('front-stage/myload.html', { userinfo: '', allonevip: allonevip })
            })
            .catch(function (error) {
                
                res.status(500).json({
                    message: '黄金vip遍历失败'
                })
            })


    } else {
        axios({
            url: "video/fan/myAttention",
            method: "GET",
            params: {
                userId: jwt.decode(req.session.token).userId
            }
        })
            .then(function (data) {
                let gzinfo = data.data.data
                        axios({
                            url: "video/order/findAllVip",
                            method: "post",
                        })
                            .then(function (data) {

                                let allonevip = data.data.object
                                axios({
                                    url: "video/fan/myFans",
                                    method: "GET",
                                    params: {
                                        userId: jwt.decode(req.session.token).userId
                                    }
                                })
                                    .then(function (data) {
                                        let info = data.data.data;
                                       
                                        axios({
                                            url: "video/verify/findAllVideoVerify",
                                            method: "get",
                                            params: {
                                                userId: jwt.decode(req.session.token).userId,
                                            }
                                        })
                                            .then(function (data) {
                                                let nosuccessvideo = data.data.data.未通过;
                                                let allvideo = data.data.data.全部的视频审核结果;
                                                let alreadysuccessvideo = data.data.data.已通过;
                                                let ingvideo = data.data.data.未审核;


                                                axios({
                                                    url: "video/findRecordByUserId",
                                                    method: "get",
                                                    params: {
                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                    }
                                                })
                                                    .then(function (data) {
                                                        // console.log(data.data.object)
                                                        let userhistory = data.data.object


                                                        axios({
                                                            url: "video/findRecordByVideoTypeNameLike",
                                                            method: "get",
                                                            params: {
                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                videoType: "电影",
                                                            }
                                                        })
                                                            .then(function (data) {
  
                                                                let userdyhistory = data.data.object
                                                                axios({
                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                    method: "get",
                                                                    params: {
                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                        videoType: "电视剧",
                                                                    }
                                                                })
                                                                    .then(function (data) {
                                                                        console.log(data.data)
                                                                        let userdsjhistory = data.data.object
                                                                        axios({
                                                                            url: "video/findRecordByVideoTypeNameLike",
                                                                            method: "get",
                                                                            params: {
                                                                                userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                videoType: "综艺",
                                                                            }
                                                                        })
                                                                            .then(function (data) {
                                                                                
                                                                                let userzyhistory = data.data.object
                                                                                axios({
                                                                                    url: "video/findRecordByVideoTypeNameLike",
                                                                                    method: "get",
                                                                                    params: {
                                                                                        userId: jwt.decode(req.session.token).userId,/*遍历用户id的历史记录id */
                                                                                        videoType: "动漫",
                                                                                    }
                                                                                })
                                                                                    .then(function (data) {
                                                                                       
                                                                                        let userdmhistory = data.data.object


                                                                                        axios({
                                                                                            url: "video/user/findUserById",
                                                                                            params: {
                                                                                                userId: jwt.decode(req.session.token).userId,
                                                                                            },
                                                                                            method: "get",
                                                                                        })
                                                                                            .then(function (data) {
                                                                                               
                                                                                                let viptype = data.data.object.vip;
                                                                                               
                                                                                                if (viptype == "0") {
                                                                                                    console.log("普通用户")
                                                                                                    res.render('front-stage/myload.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else if (viptype == "1") {
                                                                                                    console.log("vip用户")
                                                                                                    res.render('front-stage/myload.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip })
                                                                                                } else {
                                                                                                    console.log("管理员")
                                                                                                    res.render('front-stage/myload.html', { viptype: viptype, userinfo: jwt.decode(req.session.token), userdyhistory: userdyhistory, userdsjhistory: userdsjhistory, userzyhistory: userzyhistory, userdmhistory: userdmhistory, userhistory: userhistory, nosuccessvideo: nosuccessvideo, allvideo: allvideo, alreadysuccessvideo: alreadysuccessvideo, ingvideo: ingvideo, info: info, gzinfo: gzinfo, allonevip: allonevip  })
                                                                                                }






                                                                                            })
                                                                                            .catch(function (error) {
                                                                                                console.log(error)
                                                                                                res.status(500).json({
                                                                                                    message: '获取用户信息失败'
                                                                                                })
                                                                                            })













                                                                                    })
                                                                                    .catch(function (error) {
                                                                                        console.log(error)
                                                                                        res.status(500).json({
                                                                                            message: '遍历电影观看记录失败'
                                                                                        })
                                                                                    })


                                                                            })
                                                                            .catch(function (error) {
                                                                                console.log(error)
                                                                                res.status(500).json({
                                                                                    message: '遍历电影观看记录失败'
                                                                                })
                                                                            })


                                                                    })
                                                                    .catch(function (error) {
                                                                        console.log(error)
                                                                        res.status(500).json({
                                                                            message: '遍历电影观看记录失败'
                                                                        })
                                                                    })


                                                            })
                                                            .catch(function (error) {
                                                                console.log(error)
                                                                res.status(500).json({
                                                                    message: '遍历电影观看记录失败'
                                                                })
                                                            })





                                                    })
                                                    .catch(function (error) {
                                                        console.log(error)
                                                        res.status(500).json({
                                                            message: '遍历观看记录失败'
                                                        })
                                                    })






                                            })
                                            .catch(function (error) {
                                                console.log(error)
                                                res.status(500).json({
                                                    message: '查看用户的视频审核记录失败'
                                                })
                                            })



                                    })
                                    .catch(function (error) {
                                        res.status(500).json({
                                            message: '获取粉丝列表失败'
                                        })
                                    })


                            })
                            .catch(function (error) {
                                console.log(error)
                                res.status(500).json({
                                    message: '获取vip全部类型失败'
                                })
                            })


            })
            .catch(function (error) {
                res.status(500).json({
                    message: '获取关注列表失败'
                })
            })
    }

})




/*自定义注册 */
mypersonrouter.post('/addUser', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/register",
        params: {
            account: req.query.account,
            password: req.query.password
        },
        method: "post",
    })
        .then(function (data) {
           
            res.status(200).json({
                data:data.data,
                message:data.message
            })
        })
        .catch(function (error) {
          
            res.status(500).json({
                message: '注册失败'
            })
        })
})

/*自定义登录！ */

mypersonrouter.post('/toLogin', function (req, res) {
    axios({
        url: "video/user/toLogin",
        params: {
            account: req.query.account,
            password: req.query.password
        },
        method: "post",
    })
        .then(function (data) {  
           
            if(data.data.object==null){
                var aa =data.data.message
                res.status(200).json({
                    data: data.data,
                    aa:aa
                })
            }else{
               
                req.session.token = data.data.object.object
              
                res.status(200).json({
                    data: data.data,
                })
            }








        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '自定义登录失败'
            })
        })
})



/*邮箱验证码登录 */
mypersonrouter.post('/emailLogin', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/email/emailLogin",
        params: {
            code: req.query.code,
            email: req.query.email
        },
        method: "post",
    })
        .then(function (data) {
           
            req.session.token = data.data.object.object
           
            // res.redirect('/myperson')
            res.status(200).json({
                message: '邮箱验证码登录成功'
            })

        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '邮箱验证码登录失败'
            })
        })
})




/*邮箱密码登录 */
mypersonrouter.post('/loginByEmail', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/loginByEmail",
        params: {
            email: req.query.email,
            password: req.query.password
        },
        method: "post",
    })
        .then(function (data) {
           
            req.session.token = data.data.object.object
            let userData = jwt.decode(data.data.object.object);
           
            res.status(200).json({
                message: '邮箱密码登录成功'
            })

        })
        .catch(function (error) {
           
            res.status(500).json({
                message: '邮箱密码登录失败'
            })
        })
})



/*退出登录！！！ */
mypersonrouter.post('/logout', function (req, res) {
    axios({
        url: "video/user/logout",
        method: "post",
    })
        .then(function (data) {
           
            req.session.token = null;
            // res.redirect('/myperson')
            res.status(200).json({
                message: '退出登录成功'
                
            })
        })
        .catch(function (error) {
           
            res.status(500).json({
                message: '退出登录失败'
            })
        })
})




/*根据id查询用户个人信息 */
mypersonrouter.get('/findUserById', function (req, res) {
    axios({
        url: "video/user/findUserById",
        params: {
            userId: req.query.userId,
        },
        method: "get",
    })
        .then(function (data) {
            
            res.status(200).json({
                code: 200,
                data:data.data,
            })

        })
        .catch(function (error) {
           
            res.status(500).json({
                message: '获取用户信息失败'
            })
        })
})

/*上传视频 */
mypersonrouter.post('/addVideo', function (req, res) {
    axios({
        url: 'video/videoCRUD/addVideo',
        method: 'post',
        headers: {
            "Content-Type": req.headers['content-type']

        },
        
        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        responseType: 'stream',
        maxPostSize: Infinity,
        data: req
    })
        .then(response => {
       
            // 将源链接的响应头转发给下游
            for (const [key, value] of Object.entries(response.headers)) {
                res.append(key, value);
            }
        })
        .catch(error => {
            res.send('Error');
            console.error('出错：', error);
            console.error('响应：', error.response.data.read(65535).toString());
        })
});


/*新建收藏夹！！！ */

mypersonrouter.post('/addCollectionFolder', function (req, res) {
    axios({
        url: 'video/addCollectionFolder',
        method: 'post',
        params:{
            collectionFoldersName: req.query.collectionFoldersName,
            userId: req.query.userId,
        },
        
    })
        .then(function (data) {
         
            res.status(200).json({
                message: '新建收藏夹成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '新建收藏夹失败'
            })
        })
});


/*修改收藏夹封面*/
mypersonrouter.post('/updateSrc', function (req, res) {

    axios({
        url: 'video/updateSrc',
        method: 'post',
        headers: {
            "Content-Type": req.headers['content-type']
        },
        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        responseType: 'stream',
        data: req
    })
        .then(response => {

            console.log("修改收藏夹封面成功")
            // 将源链接的响应头转发给下游
            for (const [key, value] of Object.entries(response.headers)) {
                res.append(key, value);
            }
           
        })
        .catch(error => {
            res.send('Error');
            console.error('出错：', error);
            console.error('响应：', error.response.data.read(65535).toString());
        })
});





/*修改收藏夹信息 */
mypersonrouter.put('/updateCollectionFolder', function (req, res) {
    axios({
        url: 'video/updateCollectionFolder',
        method: 'put',
        params:{
            collectionFolderContent: req.query.collectionFolderContent,
            collectionFoldersId: req.query.collectionFoldersId,
            collectionFoldersName: req.query.collectionFoldersName,
        }
    })
        .then(function (data) {
            res.status(200).json({
                message: '修改收藏夹基本信息成功',
                data: data.data
            })
        })
        .catch(function (error) {
            res.status(500).json({
                message: '修改收藏夹基本信息失败'
            })
        })
});


/*遍历某用户的收藏夹 */
mypersonrouter.get('/findAllCollectionFolders', function (req, res) {
    axios({
        url: 'video/findAllCollectionFolders',
        method: 'get',
        params: {
            userId: req.query.userId,
        },
    })
        .then(function (data) {
          
            res.status(200).json({
                message: '遍历某用户的收藏夹成功',
                data:data.data
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历某用户的收藏夹失败'
            })
        })
});




/*根据收藏夹id查找收藏夹的信息进行遍历上去，以便于后面收藏夹的信息更改！！ */
mypersonrouter.get('/findCollectionFoldersById', function (req, res) {
    axios({
        url: 'video/findCollectionFoldersById',
        method: 'get',
        params: {
            collectionFoldersId: req.query.collectionFoldersId,
        },
    })
        .then(function (data) {
            console.log(data)
            res.status(200).json({
                data:data.data,
                message: '获取此收藏夹信息成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '获取此收藏夹信息失败'
            })
        })
});

/*删除收藏夹 */
mypersonrouter.delete('/deleteCollectionFolders', function (req, res) {
    axios({
        url: 'video/deleteCollectionFolders',
        method: 'DELETE',
        params: {
            collectionFoldersId: req.query.collectionFoldersId,
        },
    })
        .then(function (data) {
            console.log(data)
            res.status(200).json({
                message: '删除收藏夹成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '删除收藏夹失败'
            })
        })
});


/*邮箱注册！！！ */

mypersonrouter.put('/emailAddUser', function (req, res) {
   
    axios({
        url: "video/email/emailAddUser",
        params: {
            code: req.query.code,
            email: qs.stringify(req.query.email),
            passWord: req.query.passWord,
            rePassWord: req.query.rePassWord,
        },
        method: "put",
    })
        .then(function (data) {
           
            res.status(200).json({
                data:data.data
            })
         
            
        })
        .catch(function (error) {
           
            res.status(500).json({
                message: '邮箱注册失败'
            })
        })
})
/*发送邮箱验证码！！！ */
mypersonrouter.post('/sendEmail', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/email/sendEmail",
        params: {
            to: req.query.to,
        },
        method: "post",
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '发送邮箱验证码失败'
            })
        })
})
/*修改视频基本信息属性 */
mypersonrouter.put('/updateVideo', function (req, res) {
  
    axios({
        url: 'video/videoCRUD/updateVideo',
        method: 'put',
        params: {
            area: req.query.area,
            introduction: req.query.introduction,
            type: req.query.type,
            videoId: req.query.videoId,
            videoName: req.query.videoName,
            videoTags: req.query.videoTags,
            whetherFree: req.query.whetherFree,
            year: req.query.year,

        },

    })
        .then(function (data) {
            
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '修改视频基本信息属性失败'
            })
        })
});


/*修改视频图片信息！！！ */
mypersonrouter.post('/updateVideoPath', function (req, res) {
    axios({
        url: 'video/videoCRUD/updateVideoPath',
        method: 'post',
        headers: {
            "Content-Type": req.headers['content-type']

        },

        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        responseType: 'stream',
        maxPostSize: Infinity,
        data: req
    })
        .then(response => {
            // 将源链接的响应头转发给下游
            for (const [key, value] of Object.entries(response.headers)) {
                res.append(key, value);
            }
        })
        .catch(error => {
            res.send('Error');
            console.error('出错：', error);
            console.error('响应：', error.response.data.read(65535).toString());
        })
});





/*删除视频 */
mypersonrouter.delete('/deleteVideo', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/videoCRUD/deleteVideo",
        params: {
            videoId: req.query.videoId,
        },
        method: "delete",
    })
        .then(function (data) {
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '删除视频失败'
            })
        })
})

/*遍历视频的类型 */
mypersonrouter.get('/s', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/type/s",
        method: "get",
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历所有视频的类型失败'
            })
        })
})

/*遍历视频年份 */
mypersonrouter.get('/yearTags', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/type/yearTags",
        method: "GET",
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历所有视频年份的类型失败'
            })
        })
})

/*遍历视频资费 */
mypersonrouter.get('/whetherFree', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/type/whetherFree",
        method: "GET",
    })
        .then(function (data) {
         
            res.status(200).json({
                code: 200,
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历所有视频资费的类型失败'
            })
        })
})


/*遍历视频地区 */
mypersonrouter.get('/areaTags', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/type/areaTags",
        method: "GET",
    })
        .then(function (data) {
           
            res.status(200).json({
                code: 200,
                data: data.data,
            })
        })
        .catch(function (error) {
          
            res.status(500).json({
                message: '遍历所有视频地区的类型失败'
            })
        })
})





/*获取粉丝总数以及粉丝列表 */
mypersonrouter.get('/myFans', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/fan/myFans",
        method: "GET",
        params:{
            userId: req.query.userId,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                code: 200,
                data: data.data,

            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '获取粉丝总人数失败'
            })
        })
})

/*我的关注列表总人数以及关注总列表*/
mypersonrouter.get('/myAttention', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/fan/myAttention",
        method: "GET",
        params: {
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '获取粉丝总人数失败'
            })
        })
})


/*聚好看热度前八排行榜 */
mypersonrouter.get('/tenHotVideo', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/index/tenHotVideo",
        method: "GET",
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message:"获取热度前八成功"
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '获取热度前八失败'
            })
        })
})




/*根据用户id返回用户所有的视频用于遍历创作中心我的视频处!！！！ */
mypersonrouter.get('/findAllVideoByUserId', function (req, res) {
    axios({
        url: "video/myVideo/findAllVideoByUserId",
        method: "get",
        params: {
            pageNow: req.query.pageNow,
            pageSize: req.query.pageSize,
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '获取用户所有的视频失败'
            })
        })
})



/*取消关注！！！！ */
mypersonrouter.post('/CancelAttentionByUserIdAndNoticedId', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/fan/CancelAttentionByUserIdAndNoticedId",
        method: "post",
        params: {
            noticedId: req.query.noticedId,//被关注者id
            userId: req.query.userId,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "取关成功"
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '取关失败'
            })
        })
})


/*增加关注 */
mypersonrouter.put('/attentionOtherUser', function (req, res) {
   
    axios({
        url: "video/fan/attentionOtherUser",
        method: "put",
        params: {
            noticedId: req.query.noticedId,//关注者id
            userId: req.query.userId,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "关注成功"
            })
        })
        .catch(function (error) {
           
            res.status(500).json({
                message: '关注失败'
            })
        })
})



/*用户修改邮箱 */
mypersonrouter.put('/findAllUser', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/findAllUser",
        method: "put",
        params: {
            email: req.query.email,//用户邮箱
            userId: req.query.userId,
        }
    })
        .then(function (data) {
          
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "修改邮箱成功"
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '修改邮箱失败'
            })
        })
})




/*根据id删除用户 */
mypersonrouter.delete('/deleteById', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/deleteById",
        method: "delete",
        params: {
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            req.session.token = null;
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "删除用户(注销账号)成功"
            })

        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '删除用户(注销账号)失败'
            })
        })
})



/*查询某视频下收藏个数 */
mypersonrouter.get('/findCollectionByVideoId', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/findCollectionByVideoId",
        method: "get",
        params: {
            videoId: req.query.videoId ,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "查询某视频下收藏个数成功"
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '查询某视频下收藏个数失败'
            })
        })
})



/*取消关注 */
mypersonrouter.post('/CancelAttentionByUserIdAndNoticedId', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/fan/CancelAttentionByUserIdAndNoticedId",
        method: "post",
        params: {
            noticedId: req.query.noticedId,//关注者id
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: "取消关注成功"
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '取消关注失败'
            })
        })
})



/*修改用户头像！！！！ */
mypersonrouter.post('/updateUserSrc', function (req, res) {
    axios({
        url: 'video/user/updateUserSrc',
        method: 'post',
        headers: {
            "Content-Type": req.headers['content-type']

        },

        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        responseType: 'stream',
        maxPostSize: Infinity,
        data: req
    })
        .then(response => {
            // 将源链接的响应头转发给下游
            for (const [key, value] of Object.entries(response.headers)) {
                res.append(key, value);
            }
            // response.data.pipe(res);
            
        })
        .catch(error => {
            res.send('Error');
            console.error('出错：', error);
            console.error('响应：', error.response.data.read(65535).toString());
        })
});









/*绑定邮箱 */
mypersonrouter.put('/updatesEmail', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/email/updatesEmail",
        method: "put",
        params: {
            code: req.query.code,
            email: req.query.email,
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '绑定邮箱失败'
            })
        })
})

/*修改用户昵称 */
mypersonrouter.put('/updateUsername', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/updateUsername",
        method: "put",
        params: {
            nickname: req.query.nickname,
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '修改用户昵称失败'
            })
        })
})


/*根据账号进行修改密码 */
mypersonrouter.put('/updatePassWord', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/updatePassWord",
        method: "put",
        params: {
            account: req.query.account,
            newPassWord: req.query.newPassWord,
            oldPassWord: req.query.oldPassWord,
            rePassWord: req.query.rePassWord,
        }
    })
        .then(function (data) {
            console.log(data.data)
            req.session.token = null;
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '根据账号修改密码失败'
            })
        })
})






/*邮箱修改密码 */
mypersonrouter.put('/updatePasswordByEmail', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/email/updatePasswordByEmail",
        method: "put",
        params: {
            code: req.query.code,
            email: req.query.email,
            password: req.query.password,
            rePassword: req.query.rePassword,
            userId: req.query.rePassword,
        }
    })
        .then(function (data) {
            console.log(data.data)
            req.session.token = null;
            res.status(200).json({
                code: 200,
                data: data.data,
                message: '根据账号修改密码成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '根据账号修改密码失败'
            })
        })
})


/*邮箱找回密码 */
mypersonrouter.put('/findMissPassword', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/email/findMissPassword",
        method: "put",
        params: {
            code: req.query.code,
            email: req.query.email,
            password: req.query.password,
            rePassword: req.query.rePassword,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '根据邮箱找回密码失败'
            })
        })
})


/*添加订单的操作！！！！ */
mypersonrouter.post('/addPayOrder', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/payVipOrder/addPayOrder",
        method: "post",
        params: {
            userId: req.query.userId ,
            vipId: req.query.vipId ,
        }
    })
        .then(function (data) {
            console.log(data.data)
            // req.session.token = null;
            res.status(200).json({
                code: 200,
                data: data.data,
                message: '添加订单成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '添加订单失败'
            })
        })
})


mypersonrouter.get('/findOrderInnerJoinUser', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/payVipOrder/findOrderInnerJoinUser",
        method: "get",
        params: {
            payVipOrderId: req.query.payVipOrderId ,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: '遍历支付订单成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历支付订单失败'
            })
        })
})



/*支付操作 */
mypersonrouter.get('/payFor', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/alipay/payFor",
        method: "get",
        params: {
            payVipOrderId: req.query.payVipOrderId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: '支付订单操作成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '支付订单操作失败'
            })
        })
})


/*关键字查询用户视频 */

mypersonrouter.get('/findVideoByLikeKeyWordsLimitPage', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/myVideo/findVideoByLikeKeyWordsLimitPage",
        method: "get",
        params: {
            userId: req.query.userId,
            keyWords: req.query.keyWords,
            pageNow: req.query.pageNow,
            pageSize: req.query.pageSize,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
                message: '关键字分页查询用户视频成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '关键字分页查询用户视频失败'
            })
        })
})




mypersonrouter.get('/findTVMsgByTVId', function (req, res) {
   
    axios({
        url: "video/videoCRUD/findTVMsgByTVId",
        method: "get",
        params: {
            tvId: req.query.tvId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '根据视频id查找视频信息失败'
            })
        })
})






/*全局模糊查询作品 */
mypersonrouter.get('/findAllVideoByLikeKeyWords', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/index/findAllVideoByLikeKeyWords",
        method: "get",
        params: {
            keyWords: req.query.keyWords,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: '全局模糊查询作品成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '全局模糊查询作品失败'
            })
        })
})


/*判断用户是否充值vip以及vip到期时间 */
mypersonrouter.post('/judgeUserVipTime', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/judgeUserVipTime",
        method: "post",
        params: {
            userId: req.query.userId,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                data:data.data,
                object:data.object
            })
            
        })
        .catch(function (error) {
         
            res.status(500).json({
                message: '查询用户vip时长失败'
            })
        })
})


/*批量删除视频的操作 */
mypersonrouter.delete('/deleteMoreMyVideos', function (req, res) {
   
    axios({
        url: "video/myVideo/deleteMoreMyVideos",
        method: "delete",
        params: {
            videoIds: req.query.videoIds,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                data: data.data,
                message: '批量删除视频的操作成功'
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '批量删除视频的操作失败'
            })
        })
})


/*批量删除历史记录 */
mypersonrouter.delete('/deleteRecordList', function (req, res) {
  
    axios({
        url: "video/deleteRecordList",
        method: "delete",
        params: {
            historyRecordId: req.query.historyRecordId,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '批量删除视频的操作失败'
            })
        })
})


/*进行签到 */
mypersonrouter.post('/SignIn', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/SignIn",
        method: "post",
        params: {
            userId: req.query.userId,/*签到者id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '进行签到失败'
            })
        })
})

/*查询个人积分 */
mypersonrouter.get('/findUserPoint', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/findUserPoint",
        method: "get",
        params: {
            userId: req.query.userId,/*用户id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '查询个人积分失败'
            })
        })
})


/*积分兑换vip */


mypersonrouter.get('/updatePointToBuyVip', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/updatePointToBuyVip",
        method: "get",
        params: {
            userId: req.query.userId,/*用户id */
            vipId: req.query.vipId,/*vipid */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '积分兑换vip失败'
            })
        })
})




/*修改用户简介 */
mypersonrouter.put('/updateUserIntroduction', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/updateUserIntroduction",
        method: "put",
        params: {
            userId: req.query.userId,/*用户id */
            Introduction: req.query.Introduction,/*vipid */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '修改用户简介失败'
            })
        })
})


/*修改用户性别 */
mypersonrouter.put('/updateUserSex', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/updateUserSex",
        method: "put",
        params: {
            sex: req.query.sex,/*用户性别 */
            userId: req.query.userId,/*用户id */

        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '修改用户性别失败'
            })
        })
})


/*判断当天是否签到 */

mypersonrouter.get('/judgeSignIn', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/judgeSignIn",
        method: "get",
        params: {
            userId: req.query.userId,/*用户id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '判断当天是否签到失败'
            })
        })
    })


        /*查看用户的视频审核记录 */

//     mypersonrouter.get('/findAllVideoVerify', function (req, res) {
//         console.log(req.query)
//         axios({
//             url: "video/verify/findAllVideoVerify",
//             method: "get",
//             params: {
//                 userId: req.query.userId,/*用户id */
//             }
//         })
//             .then(function (data) {
//                 console.log(data.data)
//                 res.status(200).json({
//                     code: 200,
//                     data: data.data,
//                     message: data.data.message
//                 })
//             })
//             .catch(function (error) {
//                 console.log(error)
//                 res.status(500).json({
//                     message: '查看用户的视频审核记录失败'
//                 })
//             })
// })



/*遍历用户观看记录 */

mypersonrouter.get('/findRecordByUserId', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/findRecordByUserId",
        method: "get",
        params: {
            userId: req.query.userId,/*用户id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '遍历用户观看记录失败'
            })
        })
})



/*批量删除历史记录 */

mypersonrouter.delete('/deleteRecordList', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/deleteRecordList",
        method: "delete",
        params: {
            historyRecordId: req.query.historyRecordId,/*批量删除历史记录的数组id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                code: 200,
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '批量删除历史记录失败'
            })
        })
})



/*申请成为视频号 */
mypersonrouter.post('/askForBecomeVideoNumber', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/videoNumber/askForBecomeVideoNumber",
        method: "post",
        params: {
            userId: req.query.userId,/*申请成为视频号的用户id */
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '申请成为视频号失败'
            })
        })
})


/*判断是否是新用户！！！！ */
mypersonrouter.post('/judgeOfNewUser', function (req, res) {
    console.log(req.query)
    axios({
        url: "video/user/judgeOfNewUser",
        method: "post",
        params: {
            userId: req.query.userId,
        }
    })
        .then(function (data) {
            console.log(data.data)
            res.status(200).json({
                data: data.data,
                message: data.data.message
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '判断是否是新用户的接口失败'
            })
        })
})


/*上传电视剧接口一，上传基本信息！ */
mypersonrouter.post('/addAllTV', function (req, res) {
 
    axios({
        url: "video/tv/addAllTV",
        method: "post",
        params: {
            introduction: req.query.introduction,
            regionType: req.query.videoTyperegionType,
            userid: req.query.userid,
            videoBriefly: req.query.videoTypevideoBriefly,
            videoName: req.query.videoName,
            videoTags: req.query.videoTypevideoTags,
            videoType: req.query.videoTypevideoType,
            videoYear: req.query.videoTypevideoYear,
            whetherFree: req.query.videoTypewhetherFree,
        }
    })
        .then(function (data) {
           
            res.status(200).json({
                data: data.data,
            })
        })
        .catch(function (error) {
            console.log(error)
            res.status(500).json({
                message: '上传电视剧接口一，上传基本信息失败'
            })
        })
})


/*上传电视剧的接口二  视频数组的传递 */
mypersonrouter.post('/addTVSetNumberLink', function (req, res) {
   
    axios({
        url: 'video/tv/addTVSetNumberLink',
        method: 'post',
        headers: {
            "Content-Type": req.headers['content-type']
        },

        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        responseType: 'stream',
        maxPostSize: Infinity,
        data: req
    })
        .then(response => {
           
            // 将源链接的响应头转发给下游
            for (const [key, value] of Object.entries(response.headers)) {
                res.append(key, value);
            }
        })
        .catch(error => {
            res.send('Error');
            
            console.log(error)      
            // console.error('响应：', error.response.data.read(65535).toString());
        })
});







module.exports = mypersonrouter;



